#ifndef MODEL_H
#define MODEL_H

#include <QString>
#include <QIcon>
#include <QByteArray>
#include <QUuid>
#include <QDateTime>

namespace model {

    // 用户信息
    class UserInfo
    {
    public:
        QString userId = "";
        QString nickname = "";
        QString description = "";
        QString phone = "";
        QIcon avatar;
    };

    // 消息类型枚举
    enum MessageType {
        TEXT_TYPE,      // 文本消息
        IMAGE_TYPE,     // 图片消息
        FILE_TYPE,      // 文件消息
        SPEECH_TYPE     // 语音消息
    };

    // 消息信息
    class Message
    {
    public:
        QString messageId = "";
        QString chatSessionId = "";
        QString time = "";
        MessageType messageType = TEXT_TYPE;
        UserInfo sender;
        QByteArray content;
        QString fileId = "";
        QString fileName = "";

        // 创建文本消息[citation:5]
        static Message makeTextMessage(const QString& chatSessionId,
            const UserInfo& sender,
            const QString& text) {
            Message msg;
            msg.messageId = makeId();
            msg.chatSessionId = chatSessionId;
            msg.sender = sender;
            msg.content = text.toUtf8();
            msg.time = QDateTime::currentDateTime().toString("MM-dd HH:mm:ss");
            return msg;
        }

    private:
        static QString makeId() {
            return "M" + QUuid::createUuid().toString(QUuid::WithoutBraces).mid(1, 8);
        }
    };

    // 聊天会话信息
    class ChatSessionInfo
    {
    public:
        QString chatSessionId = "";
        QString chatSessionName = "";
        Message lastMessage;
        QIcon avatar;
    };

} // namespace model

#endif // MODEL_H
